﻿///////////////////////////////////////////////////////////////////////////////////////////////////
// AmiBroker Plug-in SDK | Copyright © 2010 by Koistya `Navin | http://code.google.com/p/amibroker/
// ------------------------------------------------------------------------------------------------
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
// except in compliance with the License. You may obtain a copy of the License at:
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software distributed under the
// License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
// either express or implied. See the License for the specific language governing permissions and
// limitations under the License.
///////////////////////////////////////////////////////////////////////////////////////////////////

using System;
using System.Runtime.InteropServices;

namespace AmiBrokerPlugin
{
    public enum InfoSiteCategory
    {
        Market,
        Group,
        Sector,
        Industry,
        Watchlist
    }

    [StructLayoutAttribute(LayoutKind.Sequential)]
    public struct InfoSite
    {
        public int StructSize;

        [UnmanagedFunctionPointer(CallingConvention.Cdecl, SetLastError = true)]
        public delegate int GetStockQtyDelegate();

        public GetStockQtyDelegate GetStockQty;

        [UnmanagedFunctionPointer(CallingConvention.Cdecl, SetLastError = true)]
        public delegate StockInfoFormat4 AddStockDelegate(string ticker);

        public AddStockDelegate AddStock;

        [UnmanagedFunctionPointer(CallingConvention.Cdecl, SetLastError = true)]
        public delegate int SetCategoryNameDelegate(int category, int item, string name);

        public SetCategoryNameDelegate SetCategoryName;

        [UnmanagedFunctionPointer(CallingConvention.Cdecl, SetLastError = true)]
        [return: MarshalAs(UnmanagedType.LPStr)]
        public delegate string GetCategoryNameDelegate(int category, int item);

        public GetCategoryNameDelegate GetCategoryName;

        [UnmanagedFunctionPointer(CallingConvention.Cdecl, SetLastError = true)]
        public delegate int SetIndustrySectorDelegate(int industry, int sector);

        public SetIndustrySectorDelegate SetIndustrySector;

        [UnmanagedFunctionPointer(CallingConvention.Cdecl, SetLastError = true)]
        public delegate int GetIndustrySectorDelegate(int industry);

        public GetIndustrySectorDelegate GetIndustrySector;

        // Only available if called from AmiBroker 5.27 or higher
        [UnmanagedFunctionPointer(CallingConvention.Cdecl, SetLastError = true)]
        public delegate IntPtr AddStockNewDelegate([MarshalAs(UnmanagedType.LPStr)] string ticker);

        public AddStockNewDelegate AddStockNew;
    }
}
